import java.util.Arrays;

public class 最大数 {
    public String largestNumber(int[] nums) {
        int n = nums.length;
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = String.valueOf(nums[i]);
        }
        Arrays.sort(s,(s1,s2) -> {
            String x = s1 + s2;
            String y = s2 + s1;
            return y.compareTo(x);
        });
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(s[i]);
        }
        if ("0".equals(s[0])) {
            return "0";
        }
        return sb.toString();
    }
}
